import React, { Fragment } from 'react';

/**
 * Fragment:
 * 1.和空标签一样，不会渲染为实体标签
 * 2.只允许两个属性存在：key、children
 */
class FragmentTest extends React.Component {

    state = {
        arr: [1,2,3,4]
    };

    render() { 
        return (
            <div>
                {
                    this.state.arr.map((v, index) => 
                        <Fragment key={index}>
                            <h2>我是标题{index}</h2>
                            <p>我是段落{index}</p>
                        </Fragment>
                    )
                }
            </div>
        )
    }
}
 
export default FragmentTest;